using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
public partial class MailMeControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        txtEmail.Text = "hello";
    }

    protected void btnSendEmail_Click(object sender, EventArgs e)
    {
        try{
        string name = txtName.Text;
        string Mailemail = txtEmail.Text;
        string Mailsubject = txtSubject.Text;
        string Mailmessage = txtMsg.Text;
        SmtpClient client = new System.Net.Mail.SmtpClient(System.Configuration.ConfigurationManager.AppSettings["mail-server"]);
        MailAddress fromAddr = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-company"]);
        SmtpPermission sett = new System.Net.Mail.SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
        //client.UseDefaultCredentials = true;
        MailAddress toAddr = new System.Net.Mail.MailAddress(Mailemail);
        MailMessage message = new System.Net.Mail.MailMessage(fromAddr, toAddr);
       // MailAddress copy = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-company"]);
        //message.CC.Add(copy);
        message.Subject = Mailsubject;
        message.Body = Mailmessage;
        message.IsBodyHtml = true;
        
        client.Send(message);
        }
        catch (Exception ex)
        {
            string exception = ex.Message;
        }

    }
}
